const int buttonPin = 09; // the number of the pushbutton pin const int ledPin_1 = 02; // the number of the LED pin 1 const int ledPin_2 = 05; // the number of the LED pin 2 int buttonState = 0; // variable for reading the pushbutton status bool pressed = false; void setup() { pinMode(ledPin_1, OUTPUT); // initialize the LED pin1 as an output: pinMode(ledPin_2, OUTPUT); // initialize the LED pin2 as an output: pinMode(buttonPin, INPUT); // initialize the button pin as an input: } void loop() { buttonState = digitalRead(buttonPin); // read the state of the pushbutton value: if (buttonState == HIGH) // check if the pushbutton is pressed. If it is, the button state is HIGH: { if (pressed == false) { pressed = true; if (digitalRead(ledPin_1) == LOW) // check whether the led1 is off, if it is then the LEDs will be HIGH { digitalWrite(ledPin_1, HIGH); digitalWrite(ledPin_2, HIGH); } else { // if led1 is on then it will turn off all the LEDs digitalWrite(ledPin_1, LOW); digitalWrite(ledPin_2, LOW); } } } else { pressed = false; delay(50); } }